Release 10.1A: OpenEdge Development:
.NET Open Clients
Using the samples
This section demonstrates using one of the .NET Open Client samples available on the Documentation and Samples CD. This sample application (written in VB.NET) is in the following location:
For more information on accessing these samples, see the information on sample Java client applications in Chapter 1, " Configuring and Deploying .NET Open Client Applications."
In this directory, you can find the following files:
Open the solution file provided,
OrderInfoDemo.sln. You will see the reference forOrderInfo, the sample's ProxyGen-generated proxy assembly (OrderInfo.dll). You can look at theOrderInforeference in the Object Browser. Expand this assembly, and you will see the following namespaces:
OrderProxyis the namespace specified on the .NET tab of the Generate dialog box in ProxyGen. Under theOrderProxynamespace, you will see theOrderInfoandCustomerOrderclasses for the AppObject and a ProcObject, respectively. Double-click on each class, to see the methods and properties available to your client.For example, under the
OrderInfoclass are the fourOrderInfo(...)constructors your client can call to create anOrderInfoinstance. These are shown with a method name ofNew. You also will see theFindCustomerByName()method, which maps to its corresponding remote 4GL method.For proxies that contain methods with a static temp-table or static DataSet parameter, ProxyGen creates a namespace called
namespace.StrongTypesNS, which contains the corresponding strongly typed DataTable and DataSet classes for that object. Here,namespaceis the namespace specified on the .NET tab of the Generate dialog box in ProxyGen, or it may be omitted. In this example, the namespace isOrderProxy.StrongTypesNS.If you expand the
OrderProxy.StrongTypesNSnamespace, you will see, for example, theOrderDetailsDataTableclass. This is the strongly typed DataTable class created by ProxyGen for the static temp-table definitionOrderDetails. You use this class in your client application when calling the corresponding AppServer method that has the static temp-table parameter. You can expand theOrderProxy.CustomerOrderclass and examine the signature of theGetOrderDetails(..)andUpdateOrderDetails(..)methods. Both these methods contain parameters of theOrderProxy.StrongTypesNS.OrderDetailsDataTableclass.Microsoft Visual Studio .NET IntelliSense provides easy access to these objects when you write your client application in the text editor. If you type the namespace of the class (for example
OrderProxy.), the following list of objects (in this example, in theOrderProxynamespace) is displayed:You can select the desired class or member and easily add it to your code.
Open the client source file,
Demo.vb. This is the sample client code that accesses the proxy classes. First, notice that the client code creates variables for each of the proxy objects, as shown:
In the subroutine for the Connect button click,
btnConnect_Click, there is the code to establish the connection to the AppServer. This code creates a connection object and then passes that object into the constructor for the AppObject,OrderInfo. This code is written within atry...catchblock, because a connection failure will be returned as an exception from the Open Client Runtime, as shown:
In the subroutine for the Search button,
btnFindByNum_Click, you will find the code to run the non-persistent procedureFindCustomerByNum. This runs the procedure on the AppServer using the connection already established. Again the proxy call is written inside atry...catchblock, as shown in the following code:
Now the client code executes a persistent procedure on the AppServer, passing it the customer number obtained from the call to the non-persistent procedure above. After the code creates the ProcObject for the persistent procedure, it calls a method on the ProcObject,
GetOrderDetails, which executes the corresponding internal procedure in the persistent procedure on the AppServer. In both cases, the code is written inside atry...catchblock, as shown:
Finally, the client code must disconnect from the AppServer. This code can be found in the subroutine for the Disconnect button,
btnDisconnect_Click. Again the proxy calls are written inside atry...catchblock, as shown in the following code:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |